/*
 * @Date: 2023-12-18 17:56:34
 * @LastEditors: 玄绮 shijiahansi@qq.com
 * @LastEditTime: 2024-04-13 13:32:28
 * @FilePath: \server\src\server\app\ChatRoomManager.h
 */
#ifndef CHATROOMMANAGER_H
#define CHATROOMMANAGER_H

#pragma once
#include "ChatRoom.h"
#include "data/UserInfo.pb.h"

#include <data/Message.pb.h>
#include <map>
#include <mysql/MysqlUtils.h>


class ChatRoomManager : private MysqlUtils {
public:
    using SharedPtr = boost::shared_ptr<ChatRoomManager>;

protected:
    std::map<std::string, ChatRoom::SharedPtr> m_chatRooms;

public:
    ChatRoomManager();
    ~ChatRoomManager();

    ChatRoom::SharedPtr getChatRoom(std::string groupId);
    ChatRoom::SharedPtr createChatRoom(data::ChatRoomInfo& info);

    void sendMessage(data::Message msg);

private:
    // 从数据库中初始化群聊
    void initChatRooms();

private:
};

#endif